package com.zj.osm.mvp;

import android.os.Bundle;

import androidx.annotation.Nullable;

import com.zj.osm.view.BaseActivity;

/**
 * 作者: Dream on 2017/8/4 22:23
 * QQ:510278658
 * E-mail:510278658@qq.com
 */

//Mvp架构设计->高度抽象Activity
public abstract class MvpActivity<V extends MvpView, P extends BasePresenter<V>> extends BaseActivity {

    private P presenter;
    private V view;

    public P getPresenter() {
        return presenter;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init();
    }

    private void init(){
        if (this.presenter == null){
            this.presenter = createPresenter();
        }
        if (this.view == null){
            this.view = createView();
        }
        if (this.presenter != null && this.view != null){
            this.presenter.attachView(this.view);
        }
    }

    //具体的Presenter我不知道，但是我知道他的爸爸是谁->BasePresenter_5
    public abstract P createPresenter();
    //具体的View我不知道，但是我知道他的爸爸是谁->MvpView_5
    public abstract V createView();

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

}
